package com.jf.cloud.service.sysmanager.common.db;

import java.util.Arrays;
import java.util.List;

public class QueryHelper { 
    /**
     * In 查询帮助类
     * 获取Key  相当于 ？
     */
	public static String getKeyForIn(List<String> params){
		StringBuffer sf = new StringBuffer(200);
		for (int i = 0;params!=null &&  i < params.size(); i++) {
			if(i>0){
				sf.append(",");
			}
			sf.append("?");
		}
		return sf.toString();
	}
	public static String getKeyForIn(String param){
		StringBuffer sf = new StringBuffer(200);
        List<String> params = null;
        if(param!=null && param.length()>0){
        	params = Arrays.asList(param.split(","));
        	sf.append(getKeyForIn(params));
        }
		return sf.toString();
	}
	/**
     * In 查询帮助类
     * 获取 value  相当于  参数
     */
    public static List<String> getValueForIn(String param){
        List<String> params = null;
        if(param!=null && param.length()>0){
        	params = Arrays.asList(param.split(","));
        }
		return params;
	}
	/**
     * In 查询帮助类,字符串类型的参数
     * 获取 value  相当于  参数
     */
    public static List<String> getCharValueForIn(String param){
        List<String> params = null;
        if(param!=null && param.length()>0){
        	String[] p = param.split(",");
        	for (int i = 0; i < p.length; i++) {
        		params.add("'"+p[i]+"'");
			} 
        }
		return params;
	}
}
